package widget;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import pojo.League;
import callback.Callback;

public class LeagueWidget extends MyButtonWidget{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String mLeagueRoomName;
	private Date mStartDate;
	private Date mEndDate;
	private int mDuration;
	
	public LeagueWidget(int posX, int posY, String backgroundEnable,
			String backgoundDisable, League league, int duration, Callback callback) {
		super(posX, posY, backgroundEnable, backgoundDisable, "", callback);
		this.mLeagueRoomName = league.getName();
		this.mStartDate = league.getStartDate();
		this.mEndDate = league.getEndDate();
		this.mDuration = duration;
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		g.setFont(new Font("Buxton Sketch", Font.BOLD, 27));
		g.setColor(Color.magenta);
		g.drawString(mLeagueRoomName, mPosX + 20, mPosY + 50);
		if(this.mDuration != 0)
		{
			g.setFont(new Font("Buxton Sketch", Font.BOLD, 20));
			DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
			if(this.mDuration == -1){
				g.setColor(Color.red);
				g.drawString("End", mPosX + 10, mPosY + 75);
				g.setColor(Color.pink);
				g.drawString(dateFormat.format(mEndDate), mPosX + 10, mPosY + 95);
			}
			else if(this.mDuration == 1){
				g.setColor(Color.green);
				g.drawString("Start", mPosX + 10, mPosY + 75);
				g.setColor(Color.pink);
				g.drawString(dateFormat.format(mStartDate), mPosX + 10, mPosY + 95);
			}
		}
	}
}
